package com.suixuan.support.util;

import java.io.IOException;
import java.util.Properties;

import org.springframework.core.io.support.PropertiesLoaderUtils;

import com.suixuan.support.log.LogConstant;
import com.suixuan.support.log.LogFactory;

/**
 * Nanjing Zhou Su co.,Ltd
 * 
 * @Title: ErrorCodeUtils.java
 * @Package: com.suixuan.spring.util
 * @Description: 读取错误码
 * @Author: suixuan
 * @Date 2010-3-15 下午03:20:46
 * @Version V1.0
 */
public final class ErrorCodeUtils {

	private ErrorCodeUtils() {
		super();
	}

	/**
	 * 加载properties文件 by suixuan begin
	 */
	private static Properties props = new Properties();

	static {
		try {
			props = PropertiesLoaderUtils.loadAllProperties("errorCode.properties");
		} catch (IOException e) {
			// 记录加载资源文件失败日志
			LogFactory.getInstance(ErrorCodeUtils.class).logRecord(LogConstant.ERROR, e.toString(), e);
		}
	}

	/**
	 * 依据错误码返回错误描述
	 * 
	 * @param errorCode
	 *            错误码
	 * @return 错误描述
	 */
	public static String getErrorDescription(Long errorCode) {

		return props.getProperty(errorCode.toString());
	}
}
